package we.core.bean;

import java.nio.channels.SocketChannel;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;


public class CUser {
    static AtomicInteger idSequence = new AtomicInteger(0);
    public String username;
    public SocketChannel channel;
    public int roomId;
    public int userId;
    public Map<String, String> properties = new HashMap<String, String>();

    @Override
    public String toString() {
        String result =
            "{username = " + username + ", roomID = " + roomId + ", properties = " +
            properties + "}";
        return result;
    }

    public CUser() {
        userId = idSequence.getAndIncrement();
    }

    public CUser(String username, SocketChannel channel, int roomId,
                Map<String, String> properties) {
        this.username = username;
        this.channel = channel;
        this.roomId = roomId;
        this.properties = properties;
        userId = idSequence.getAndIncrement();
    }
}
